import request from "@/api";
import { BaseRet, ListRet } from "@/api/response";
import { MenuTypeEnum } from "@/enums/MenuTypeEnum";

class RoleMenuApi {
  /**
   * 查询
   * @param roleId
   * @returns
   */
  static async query(roleId: string): Promise<ListRet<RoleMenu>> {
    return await request({
      url: `sysRoleMenu/Index/${roleId}`,
      method: "get",
    });
  }
  /**
   * 新增
   * @param data
   * @returns
   */
  static async create(data: RoleMenuCreate): Promise<BaseRet> {
    return await request({
      url: "/sysRoleMenu/create",
      method: "post",
      data: data,
    });
  }
}

export default RoleMenuApi;

export interface RoleMenu {
  id: string;
  name: string;
  isCurrentRole: boolean;
  menuType: MenuTypeEnum;
  children: RoleMenu[];
}

export interface RoleMenuCreate {
  roleId: string;
  menuIdList: string[];
}
